package com.iRomantic.controller.manager;

import com.iRomantic.common.BaseController;
import com.iRomantic.common.oss.OSSService;
import com.iRomantic.config.Constant;
import com.iRomantic.domain.entity.Version;
import com.jfinal.upload.UploadFile;

public class VersionController extends BaseController{
	
	public void create() throws Exception{
		String path = this.getSession().getServletContext().getRealPath(Constant.TEMP_FOLDER);
		UploadFile  newVersion = this.getFile("file",path,200*1024*1024);
		Version version = this.getModel(Version.class);
		OSSService.getInstance().save(Constant.VERSION_PACKAGE+newVersion.getFileName(),newVersion.getFile());
		version.set("url", newVersion.getFileName());
		version.save();
		newVersion.getFile().delete();
		renderJson(version);
	}
	
}
